{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 样本交易特征统计\n",
    "- 以账期订单为样本"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "#读取所有文件\n",
    "import pandas as pd\n",
    "import os\n",
    "import numpy as np\n",
    "import re\n",
    "from funcs import *\n",
    "import sys  \n",
    "reload(sys)  \n",
    "sys.setdefaultencoding('utf8')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "#统计每个客户账期订单数据\n",
    "indexs = ['订单总数','合作时间（月）','最近交易（X月之前）','最近连续交易月数','采购断档总月数','订单时间间隔均值（天）','订单时间间隔方差（天）',\n",
    "          '交易总量','交易量最大值','交易量最小值','交易量方差','交易量均值','交易额总量','交易额最大值','交易额最小值','交易额方差','交易额均值',\n",
    "          '交易稳定性','供应商数量','采购产品种类数量',\n",
    "          '账期订单占比','账期订单交易量均值','账期订单交易额均值','账期合作时间（月）','最近一笔账期订单（X月之前）']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "#统计所有交易特征\n",
    "def ac_feature(trade,t_now):\n",
    "    feature = []\n",
    "    num = trade.shape[0] #订单数\n",
    "    coo_month = coo_months(trade[u'创建时间'])  #合作时间（月）\n",
    "    feature.append(num)\n",
    "    feature.append(coo_month)\n",
    "    feature.append(recent_month(trade[u'创建时间'],t_now))\n",
    "    feature.append(recent_last_month(trade[u'创建时间']))\n",
    "    \n",
    "    purchase_month = purchase_months(trade[u'创建时间'])\n",
    "    gap_months = coo_month-purchase_month  #采购断档总月数\n",
    "    feature.append(gap_months)\n",
    "    \n",
    "    tim_st = time_gap(trade[u'创建时间'])\n",
    "    feature.append(tim_st[0]) #均值\n",
    "    feature.append(tim_st[1]) #方差\n",
    "    \n",
    "    t_num = trade[u'销售数量（吨）'].agg(['sum','max','min','std','mean'])\n",
    "    t_money = trade[u'销售金额（元）'].agg(['sum','max','min','std','mean'])\n",
    "    feature.extend(t_num)\n",
    "    feature.extend(t_money)\n",
    "    \n",
    "    feature.append(trade_stab_all(trade))\n",
    "    feature.append(trade[u'货物'].apply(lambda x:x.split(' ')[1]).value_counts().shape[0])\n",
    "    feature.append(trade[u'货物'].apply(lambda x:x.split(' ')[0]).value_counts().shape[0])\n",
    "        \n",
    "    zhangqi = trade[trade[u'是否账期']==u'是']\n",
    "    if zhangqi.shape[0]>0:\n",
    "        feature.append(zhangqi.shape[0]*1.0/num)\n",
    "        feature.append(zhangqi[u'销售数量（吨）'].mean())\n",
    "        feature.append(zhangqi[u'销售金额（元）'].mean())\n",
    "        feature.append(coo_months(zhangqi[u'创建时间']))\n",
    "        feature.append(recent_month(zhangqi[u'创建时间'],t_now))\n",
    "    else:\n",
    "        feature.append(0)\n",
    "        feature.append(0)\n",
    "        feature.append(0)\n",
    "        feature.append(0)\n",
    "        feature.append(np.nan)\n",
    "    return feature"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "def df_sub(record,trade):\n",
    "    df = pd.DataFrame(index=indexs)    \n",
    "    tmps = zip(record[u'应收单号'],record[u'起算日期'])\n",
    "    for t in tmps:\n",
    "        trade_sub = trade[trade[u'创建时间']<t[1]]\n",
    "        if trade_sub.shape[0]>1:\n",
    "            fs = ac_feature(trade_sub.iloc[1:,:],t[1])\n",
    "        else:\n",
    "            fs = [np.nan]*len(indexs)\n",
    "        df[t[0]]=fs\n",
    "    return df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "#所有账期订单数据统计\n",
    "zq_files = os.listdir('./data/loan_list/')\n",
    "#所有订单数据\n",
    "files = VisitDir('./data/client_data/')\n",
    "files =[f for f in files if '交易记录' in f]\n",
    "\n",
    "samples = pd.DataFrame()\n",
    "for f in zq_files:\n",
    "    record = pd.read_excel(os.path.join('./data/loan_list/',f))\n",
    "    record = record.iloc[1:,:]  #账期数据\n",
    "    for f1 in files:\n",
    "        if f1.split('/')[-2]==f.split('.')[0]:\n",
    "            trade = pd.read_excel(f1)   #交易数据\n",
    "            df = df_sub(record,trade)          \n",
    "            if samples.shape[0]==0:\n",
    "                samples=df\n",
    "            else:\n",
    "                samples = samples.merge(df,left_index=True,right_index=True,how='left')\n",
    "            continue\n",
    "\n",
    "samples =samples.T"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>订单总数</th>\n",
       "      <th>合作时间（月）</th>\n",
       "      <th>最近交易（X月之前）</th>\n",
       "      <th>最近连续交易月数</th>\n",
       "      <th>采购断档总月数</th>\n",
       "      <th>订单时间间隔均值（天）</th>\n",
       "      <th>订单时间间隔方差（天）</th>\n",
       "      <th>交易总量</th>\n",
       "      <th>交易量最大值</th>\n",
       "      <th>交易量最小值</th>\n",
       "      <th>...</th>\n",
       "      <th>交易稳定性</th>\n",
       "      <th>供应商数量</th>\n",
       "      <th>采购产品种类数量</th>\n",
       "      <th>账期订单占比</th>\n",
       "      <th>账期订单交易量均值</th>\n",
       "      <th>账期订单交易额均值</th>\n",
       "      <th>账期合作时间（月）</th>\n",
       "      <th>最近一笔账期订单（X月之前）</th>\n",
       "      <th>采购频率（订单总数/合作月数）</th>\n",
       "      <th>采购聚集程度（订单总数/供应商数）</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>YS20170228152309</th>\n",
       "      <td>18.0</td>\n",
       "      <td>12.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>18.588235</td>\n",
       "      <td>15.544528</td>\n",
       "      <td>556.75</td>\n",
       "      <td>54.00</td>\n",
       "      <td>20.00</td>\n",
       "      <td>...</td>\n",
       "      <td>0.062321</td>\n",
       "      <td>5.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.888889</td>\n",
       "      <td>30.609375</td>\n",
       "      <td>188399.218750</td>\n",
       "      <td>10.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>1.500000</td>\n",
       "      <td>3.600000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS20170103150373</th>\n",
       "      <td>16.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>16.333333</td>\n",
       "      <td>10.668155</td>\n",
       "      <td>502.75</td>\n",
       "      <td>54.00</td>\n",
       "      <td>20.00</td>\n",
       "      <td>...</td>\n",
       "      <td>0.103964</td>\n",
       "      <td>5.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.937500</td>\n",
       "      <td>30.850000</td>\n",
       "      <td>189493.166667</td>\n",
       "      <td>8.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.777778</td>\n",
       "      <td>3.200000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS20161117147341</th>\n",
       "      <td>15.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>16.642857</td>\n",
       "      <td>11.000749</td>\n",
       "      <td>448.75</td>\n",
       "      <td>50.00</td>\n",
       "      <td>20.00</td>\n",
       "      <td>...</td>\n",
       "      <td>0.034467</td>\n",
       "      <td>5.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.933333</td>\n",
       "      <td>29.196429</td>\n",
       "      <td>174678.392857</td>\n",
       "      <td>8.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.666667</td>\n",
       "      <td>3.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS20161115147142</th>\n",
       "      <td>15.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>16.642857</td>\n",
       "      <td>11.000749</td>\n",
       "      <td>448.75</td>\n",
       "      <td>50.00</td>\n",
       "      <td>20.00</td>\n",
       "      <td>...</td>\n",
       "      <td>0.034467</td>\n",
       "      <td>5.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.933333</td>\n",
       "      <td>29.196429</td>\n",
       "      <td>174678.392857</td>\n",
       "      <td>8.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.666667</td>\n",
       "      <td>3.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS20161025145675</th>\n",
       "      <td>14.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>17.769231</td>\n",
       "      <td>10.576340</td>\n",
       "      <td>422.75</td>\n",
       "      <td>50.00</td>\n",
       "      <td>20.00</td>\n",
       "      <td>...</td>\n",
       "      <td>0.037118</td>\n",
       "      <td>5.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.928571</td>\n",
       "      <td>29.442308</td>\n",
       "      <td>173615.192308</td>\n",
       "      <td>8.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.555556</td>\n",
       "      <td>2.800000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS20161019110425</th>\n",
       "      <td>14.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>17.769231</td>\n",
       "      <td>10.576340</td>\n",
       "      <td>422.75</td>\n",
       "      <td>50.00</td>\n",
       "      <td>20.00</td>\n",
       "      <td>...</td>\n",
       "      <td>0.037118</td>\n",
       "      <td>5.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.928571</td>\n",
       "      <td>29.442308</td>\n",
       "      <td>173615.192308</td>\n",
       "      <td>8.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.555556</td>\n",
       "      <td>2.800000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS20160926108844</th>\n",
       "      <td>12.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>16.090909</td>\n",
       "      <td>10.064338</td>\n",
       "      <td>346.75</td>\n",
       "      <td>50.00</td>\n",
       "      <td>20.00</td>\n",
       "      <td>...</td>\n",
       "      <td>0.031785</td>\n",
       "      <td>5.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.916667</td>\n",
       "      <td>27.886364</td>\n",
       "      <td>156459.772727</td>\n",
       "      <td>6.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.714286</td>\n",
       "      <td>2.400000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS20160926108834</th>\n",
       "      <td>12.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>16.090909</td>\n",
       "      <td>10.064338</td>\n",
       "      <td>346.75</td>\n",
       "      <td>50.00</td>\n",
       "      <td>20.00</td>\n",
       "      <td>...</td>\n",
       "      <td>0.031785</td>\n",
       "      <td>5.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.916667</td>\n",
       "      <td>27.886364</td>\n",
       "      <td>156459.772727</td>\n",
       "      <td>6.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.714286</td>\n",
       "      <td>2.400000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS20160824106578</th>\n",
       "      <td>11.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>16.700000</td>\n",
       "      <td>10.392839</td>\n",
       "      <td>315.75</td>\n",
       "      <td>50.00</td>\n",
       "      <td>20.00</td>\n",
       "      <td>...</td>\n",
       "      <td>0.034963</td>\n",
       "      <td>5.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.909091</td>\n",
       "      <td>27.575000</td>\n",
       "      <td>153226.750000</td>\n",
       "      <td>6.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.571429</td>\n",
       "      <td>2.200000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS20160811171089</th>\n",
       "      <td>10.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>17.777778</td>\n",
       "      <td>10.413666</td>\n",
       "      <td>284.75</td>\n",
       "      <td>50.00</td>\n",
       "      <td>20.00</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.022263</td>\n",
       "      <td>4.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.900000</td>\n",
       "      <td>27.194444</td>\n",
       "      <td>150101.944444</td>\n",
       "      <td>6.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.428571</td>\n",
       "      <td>2.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS2016080317738</th>\n",
       "      <td>9.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>18.250000</td>\n",
       "      <td>11.029182</td>\n",
       "      <td>264.75</td>\n",
       "      <td>50.00</td>\n",
       "      <td>20.00</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.025046</td>\n",
       "      <td>4.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.888889</td>\n",
       "      <td>28.093750</td>\n",
       "      <td>154389.687500</td>\n",
       "      <td>5.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.500000</td>\n",
       "      <td>2.250000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS2016071915487</th>\n",
       "      <td>8.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>17.142857</td>\n",
       "      <td>11.422617</td>\n",
       "      <td>244.75</td>\n",
       "      <td>50.00</td>\n",
       "      <td>20.00</td>\n",
       "      <td>...</td>\n",
       "      <td>0.013095</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.875000</td>\n",
       "      <td>29.250000</td>\n",
       "      <td>159931.071429</td>\n",
       "      <td>4.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.600000</td>\n",
       "      <td>2.666667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS2016070113517</th>\n",
       "      <td>7.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>18.500000</td>\n",
       "      <td>11.878552</td>\n",
       "      <td>216.50</td>\n",
       "      <td>50.00</td>\n",
       "      <td>20.00</td>\n",
       "      <td>...</td>\n",
       "      <td>0.015278</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.857143</td>\n",
       "      <td>29.416667</td>\n",
       "      <td>161490.833333</td>\n",
       "      <td>4.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.400000</td>\n",
       "      <td>2.333333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS2016061410728</th>\n",
       "      <td>6.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>14.200000</td>\n",
       "      <td>6.140033</td>\n",
       "      <td>188.25</td>\n",
       "      <td>50.00</td>\n",
       "      <td>20.00</td>\n",
       "      <td>...</td>\n",
       "      <td>0.018333</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.833333</td>\n",
       "      <td>29.650000</td>\n",
       "      <td>163731.000000</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.500000</td>\n",
       "      <td>2.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS2016050505611</th>\n",
       "      <td>5.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>12.250000</td>\n",
       "      <td>4.991660</td>\n",
       "      <td>160.00</td>\n",
       "      <td>50.00</td>\n",
       "      <td>20.00</td>\n",
       "      <td>...</td>\n",
       "      <td>0.037500</td>\n",
       "      <td>2.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.800000</td>\n",
       "      <td>30.000000</td>\n",
       "      <td>166950.000000</td>\n",
       "      <td>2.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.666667</td>\n",
       "      <td>2.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS2016041503344</th>\n",
       "      <td>4.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>11.333333</td>\n",
       "      <td>5.686241</td>\n",
       "      <td>130.00</td>\n",
       "      <td>50.00</td>\n",
       "      <td>20.00</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.116667</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.750000</td>\n",
       "      <td>30.000000</td>\n",
       "      <td>166900.000000</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>4.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS2016033002161</th>\n",
       "      <td>3.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>14.500000</td>\n",
       "      <td>2.121320</td>\n",
       "      <td>110.00</td>\n",
       "      <td>50.00</td>\n",
       "      <td>20.00</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.175000</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.666667</td>\n",
       "      <td>35.000000</td>\n",
       "      <td>193550.000000</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.500000</td>\n",
       "      <td>3.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS2016032801981</th>\n",
       "      <td>2.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>13.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>90.00</td>\n",
       "      <td>50.00</td>\n",
       "      <td>40.00</td>\n",
       "      <td>...</td>\n",
       "      <td>0.250000</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>50.000000</td>\n",
       "      <td>273500.000000</td>\n",
       "      <td>1.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>2.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS2016031500502</th>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>40.00</td>\n",
       "      <td>40.00</td>\n",
       "      <td>40.00</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS2016031500501</th>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>40.00</td>\n",
       "      <td>40.00</td>\n",
       "      <td>40.00</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>1.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS20170313152947</th>\n",
       "      <td>13.0</td>\n",
       "      <td>12.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>26.833333</td>\n",
       "      <td>19.192012</td>\n",
       "      <td>624.00</td>\n",
       "      <td>78.75</td>\n",
       "      <td>26.00</td>\n",
       "      <td>...</td>\n",
       "      <td>0.250159</td>\n",
       "      <td>4.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.769231</td>\n",
       "      <td>47.750000</td>\n",
       "      <td>291668.250000</td>\n",
       "      <td>9.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>1.083333</td>\n",
       "      <td>3.250000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS20170310152860</th>\n",
       "      <td>13.0</td>\n",
       "      <td>12.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>26.833333</td>\n",
       "      <td>19.192012</td>\n",
       "      <td>624.00</td>\n",
       "      <td>78.75</td>\n",
       "      <td>26.00</td>\n",
       "      <td>...</td>\n",
       "      <td>0.250159</td>\n",
       "      <td>4.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.769231</td>\n",
       "      <td>47.750000</td>\n",
       "      <td>291668.250000</td>\n",
       "      <td>9.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>1.083333</td>\n",
       "      <td>3.250000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS20170306152576</th>\n",
       "      <td>13.0</td>\n",
       "      <td>12.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>26.833333</td>\n",
       "      <td>19.192012</td>\n",
       "      <td>624.00</td>\n",
       "      <td>78.75</td>\n",
       "      <td>26.00</td>\n",
       "      <td>...</td>\n",
       "      <td>0.250159</td>\n",
       "      <td>4.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.769231</td>\n",
       "      <td>47.750000</td>\n",
       "      <td>291668.250000</td>\n",
       "      <td>9.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>1.083333</td>\n",
       "      <td>3.250000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS20161214149147</th>\n",
       "      <td>12.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>26.636364</td>\n",
       "      <td>20.116027</td>\n",
       "      <td>545.25</td>\n",
       "      <td>60.00</td>\n",
       "      <td>26.00</td>\n",
       "      <td>...</td>\n",
       "      <td>0.088460</td>\n",
       "      <td>4.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.750000</td>\n",
       "      <td>44.305556</td>\n",
       "      <td>252063.333333</td>\n",
       "      <td>8.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>1.090909</td>\n",
       "      <td>3.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS20161201148307</th>\n",
       "      <td>12.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>26.636364</td>\n",
       "      <td>20.116027</td>\n",
       "      <td>545.25</td>\n",
       "      <td>60.00</td>\n",
       "      <td>26.00</td>\n",
       "      <td>...</td>\n",
       "      <td>0.088460</td>\n",
       "      <td>4.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.750000</td>\n",
       "      <td>44.305556</td>\n",
       "      <td>252063.333333</td>\n",
       "      <td>8.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>1.090909</td>\n",
       "      <td>3.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS20161130148192</th>\n",
       "      <td>12.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>26.636364</td>\n",
       "      <td>20.116027</td>\n",
       "      <td>545.25</td>\n",
       "      <td>60.00</td>\n",
       "      <td>26.00</td>\n",
       "      <td>...</td>\n",
       "      <td>0.088460</td>\n",
       "      <td>4.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.750000</td>\n",
       "      <td>44.305556</td>\n",
       "      <td>252063.333333</td>\n",
       "      <td>8.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.090909</td>\n",
       "      <td>3.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS20161019110385</th>\n",
       "      <td>11.0</td>\n",
       "      <td>10.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>26.000000</td>\n",
       "      <td>21.087121</td>\n",
       "      <td>519.25</td>\n",
       "      <td>60.00</td>\n",
       "      <td>28.00</td>\n",
       "      <td>...</td>\n",
       "      <td>0.153973</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.727273</td>\n",
       "      <td>46.593750</td>\n",
       "      <td>259911.250000</td>\n",
       "      <td>7.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.100000</td>\n",
       "      <td>3.666667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS20160913107905</th>\n",
       "      <td>10.0</td>\n",
       "      <td>8.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>23.444444</td>\n",
       "      <td>20.658601</td>\n",
       "      <td>459.25</td>\n",
       "      <td>60.00</td>\n",
       "      <td>28.00</td>\n",
       "      <td>...</td>\n",
       "      <td>0.164198</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.700000</td>\n",
       "      <td>44.678571</td>\n",
       "      <td>243555.714286</td>\n",
       "      <td>5.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>1.250000</td>\n",
       "      <td>3.333333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS20160911107730</th>\n",
       "      <td>10.0</td>\n",
       "      <td>8.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>23.444444</td>\n",
       "      <td>20.658601</td>\n",
       "      <td>459.25</td>\n",
       "      <td>60.00</td>\n",
       "      <td>28.00</td>\n",
       "      <td>...</td>\n",
       "      <td>0.164198</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.700000</td>\n",
       "      <td>44.678571</td>\n",
       "      <td>243555.714286</td>\n",
       "      <td>5.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>1.250000</td>\n",
       "      <td>3.333333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS2016072516482</th>\n",
       "      <td>9.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>23.625000</td>\n",
       "      <td>22.077380</td>\n",
       "      <td>402.75</td>\n",
       "      <td>60.00</td>\n",
       "      <td>28.00</td>\n",
       "      <td>...</td>\n",
       "      <td>0.057490</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.666667</td>\n",
       "      <td>42.708333</td>\n",
       "      <td>230567.500000</td>\n",
       "      <td>4.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.285714</td>\n",
       "      <td>3.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS20161008109412</th>\n",
       "      <td>51.0</td>\n",
       "      <td>15.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>15.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>10.309524</td>\n",
       "      <td>10.966664</td>\n",
       "      <td>1670.05</td>\n",
       "      <td>113.00</td>\n",
       "      <td>0.05</td>\n",
       "      <td>...</td>\n",
       "      <td>14.597634</td>\n",
       "      <td>12.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.470588</td>\n",
       "      <td>35.302083</td>\n",
       "      <td>199068.437500</td>\n",
       "      <td>7.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>3.400000</td>\n",
       "      <td>4.250000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS20160923108748</th>\n",
       "      <td>50.0</td>\n",
       "      <td>15.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>15.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>10.309524</td>\n",
       "      <td>10.966664</td>\n",
       "      <td>1644.05</td>\n",
       "      <td>113.00</td>\n",
       "      <td>0.05</td>\n",
       "      <td>...</td>\n",
       "      <td>14.898266</td>\n",
       "      <td>12.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.460000</td>\n",
       "      <td>35.706522</td>\n",
       "      <td>199980.108696</td>\n",
       "      <td>7.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3.333333</td>\n",
       "      <td>4.166667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS20160905107298</th>\n",
       "      <td>47.0</td>\n",
       "      <td>13.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>13.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.717949</td>\n",
       "      <td>10.236541</td>\n",
       "      <td>1552.05</td>\n",
       "      <td>113.00</td>\n",
       "      <td>0.05</td>\n",
       "      <td>...</td>\n",
       "      <td>15.881463</td>\n",
       "      <td>12.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.425532</td>\n",
       "      <td>36.462500</td>\n",
       "      <td>200576.625000</td>\n",
       "      <td>5.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>3.615385</td>\n",
       "      <td>3.916667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS20160824106576</th>\n",
       "      <td>47.0</td>\n",
       "      <td>13.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>13.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.717949</td>\n",
       "      <td>10.236541</td>\n",
       "      <td>1552.05</td>\n",
       "      <td>113.00</td>\n",
       "      <td>0.05</td>\n",
       "      <td>...</td>\n",
       "      <td>15.881463</td>\n",
       "      <td>12.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.425532</td>\n",
       "      <td>36.462500</td>\n",
       "      <td>200576.625000</td>\n",
       "      <td>5.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>3.615385</td>\n",
       "      <td>3.916667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS20160812171110</th>\n",
       "      <td>47.0</td>\n",
       "      <td>13.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>13.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.717949</td>\n",
       "      <td>10.236541</td>\n",
       "      <td>1552.05</td>\n",
       "      <td>113.00</td>\n",
       "      <td>0.05</td>\n",
       "      <td>...</td>\n",
       "      <td>15.881463</td>\n",
       "      <td>12.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.425532</td>\n",
       "      <td>36.462500</td>\n",
       "      <td>200576.625000</td>\n",
       "      <td>5.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>3.615385</td>\n",
       "      <td>3.916667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS2016072917121</th>\n",
       "      <td>45.0</td>\n",
       "      <td>13.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>13.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.783784</td>\n",
       "      <td>10.363223</td>\n",
       "      <td>1459.05</td>\n",
       "      <td>113.00</td>\n",
       "      <td>0.05</td>\n",
       "      <td>...</td>\n",
       "      <td>16.580620</td>\n",
       "      <td>12.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.400000</td>\n",
       "      <td>35.347222</td>\n",
       "      <td>193602.361111</td>\n",
       "      <td>5.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3.461538</td>\n",
       "      <td>3.750000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS2016071815393</th>\n",
       "      <td>45.0</td>\n",
       "      <td>13.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>13.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.783784</td>\n",
       "      <td>10.363223</td>\n",
       "      <td>1459.05</td>\n",
       "      <td>113.00</td>\n",
       "      <td>0.05</td>\n",
       "      <td>...</td>\n",
       "      <td>16.580620</td>\n",
       "      <td>12.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.400000</td>\n",
       "      <td>35.347222</td>\n",
       "      <td>193602.361111</td>\n",
       "      <td>5.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3.461538</td>\n",
       "      <td>3.750000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS2016070814239</th>\n",
       "      <td>41.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.151515</td>\n",
       "      <td>10.295998</td>\n",
       "      <td>1341.05</td>\n",
       "      <td>113.00</td>\n",
       "      <td>0.05</td>\n",
       "      <td>...</td>\n",
       "      <td>18.249337</td>\n",
       "      <td>10.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.341463</td>\n",
       "      <td>37.017857</td>\n",
       "      <td>202824.464286</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>3.727273</td>\n",
       "      <td>4.100000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS2016070814238</th>\n",
       "      <td>40.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.343750</td>\n",
       "      <td>10.400401</td>\n",
       "      <td>1281.05</td>\n",
       "      <td>113.00</td>\n",
       "      <td>0.05</td>\n",
       "      <td>...</td>\n",
       "      <td>18.715437</td>\n",
       "      <td>9.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.325000</td>\n",
       "      <td>35.250000</td>\n",
       "      <td>193180.192308</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>3.636364</td>\n",
       "      <td>4.444444</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS2016070413660</th>\n",
       "      <td>43.0</td>\n",
       "      <td>12.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>12.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.714286</td>\n",
       "      <td>10.659355</td>\n",
       "      <td>1397.05</td>\n",
       "      <td>113.00</td>\n",
       "      <td>0.05</td>\n",
       "      <td>...</td>\n",
       "      <td>17.367622</td>\n",
       "      <td>11.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.372093</td>\n",
       "      <td>35.890625</td>\n",
       "      <td>196528.906250</td>\n",
       "      <td>4.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>3.583333</td>\n",
       "      <td>3.909091</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS2016062913095</th>\n",
       "      <td>42.0</td>\n",
       "      <td>12.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>12.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.794118</td>\n",
       "      <td>10.809029</td>\n",
       "      <td>1369.05</td>\n",
       "      <td>113.00</td>\n",
       "      <td>0.05</td>\n",
       "      <td>...</td>\n",
       "      <td>17.791223</td>\n",
       "      <td>11.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.357143</td>\n",
       "      <td>36.416667</td>\n",
       "      <td>199214.833333</td>\n",
       "      <td>4.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3.500000</td>\n",
       "      <td>3.818182</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS2016061410578</th>\n",
       "      <td>41.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.151515</td>\n",
       "      <td>10.295998</td>\n",
       "      <td>1341.05</td>\n",
       "      <td>113.00</td>\n",
       "      <td>0.05</td>\n",
       "      <td>...</td>\n",
       "      <td>18.249337</td>\n",
       "      <td>10.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.341463</td>\n",
       "      <td>37.017857</td>\n",
       "      <td>202824.464286</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>3.727273</td>\n",
       "      <td>4.100000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS2016060209464</th>\n",
       "      <td>40.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.343750</td>\n",
       "      <td>10.400401</td>\n",
       "      <td>1281.05</td>\n",
       "      <td>113.00</td>\n",
       "      <td>0.05</td>\n",
       "      <td>...</td>\n",
       "      <td>18.715437</td>\n",
       "      <td>9.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.325000</td>\n",
       "      <td>35.250000</td>\n",
       "      <td>193180.192308</td>\n",
       "      <td>3.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3.636364</td>\n",
       "      <td>4.444444</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS2016060109379</th>\n",
       "      <td>40.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.343750</td>\n",
       "      <td>10.400401</td>\n",
       "      <td>1281.05</td>\n",
       "      <td>113.00</td>\n",
       "      <td>0.05</td>\n",
       "      <td>...</td>\n",
       "      <td>18.715437</td>\n",
       "      <td>9.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.325000</td>\n",
       "      <td>35.250000</td>\n",
       "      <td>193180.192308</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>3.636364</td>\n",
       "      <td>4.444444</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS2016051807334</th>\n",
       "      <td>40.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.343750</td>\n",
       "      <td>10.400401</td>\n",
       "      <td>1281.05</td>\n",
       "      <td>113.00</td>\n",
       "      <td>0.05</td>\n",
       "      <td>...</td>\n",
       "      <td>18.715437</td>\n",
       "      <td>9.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.325000</td>\n",
       "      <td>35.250000</td>\n",
       "      <td>193180.192308</td>\n",
       "      <td>3.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3.636364</td>\n",
       "      <td>4.444444</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS2016051606780</th>\n",
       "      <td>39.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.516129</td>\n",
       "      <td>10.525749</td>\n",
       "      <td>1225.05</td>\n",
       "      <td>113.00</td>\n",
       "      <td>0.05</td>\n",
       "      <td>...</td>\n",
       "      <td>19.181633</td>\n",
       "      <td>9.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.307692</td>\n",
       "      <td>33.520833</td>\n",
       "      <td>184498.541667</td>\n",
       "      <td>3.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3.545455</td>\n",
       "      <td>4.333333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS2016051006122</th>\n",
       "      <td>38.0</td>\n",
       "      <td>10.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>10.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.333333</td>\n",
       "      <td>10.655526</td>\n",
       "      <td>1197.05</td>\n",
       "      <td>113.00</td>\n",
       "      <td>0.05</td>\n",
       "      <td>...</td>\n",
       "      <td>19.713688</td>\n",
       "      <td>8.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.289474</td>\n",
       "      <td>34.022727</td>\n",
       "      <td>187754.772727</td>\n",
       "      <td>2.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>3.800000</td>\n",
       "      <td>4.750000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS2016042905377</th>\n",
       "      <td>37.0</td>\n",
       "      <td>10.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>10.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.379310</td>\n",
       "      <td>10.841105</td>\n",
       "      <td>1140.55</td>\n",
       "      <td>113.00</td>\n",
       "      <td>0.05</td>\n",
       "      <td>...</td>\n",
       "      <td>20.233017</td>\n",
       "      <td>8.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.270270</td>\n",
       "      <td>31.775000</td>\n",
       "      <td>174890.250000</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3.700000</td>\n",
       "      <td>4.625000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS2016042705087</th>\n",
       "      <td>37.0</td>\n",
       "      <td>10.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>10.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.379310</td>\n",
       "      <td>10.841105</td>\n",
       "      <td>1140.55</td>\n",
       "      <td>113.00</td>\n",
       "      <td>0.05</td>\n",
       "      <td>...</td>\n",
       "      <td>20.233017</td>\n",
       "      <td>8.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.270270</td>\n",
       "      <td>31.775000</td>\n",
       "      <td>174890.250000</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3.700000</td>\n",
       "      <td>4.625000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS2016041803663</th>\n",
       "      <td>36.0</td>\n",
       "      <td>10.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>10.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.535714</td>\n",
       "      <td>11.006672</td>\n",
       "      <td>1112.55</td>\n",
       "      <td>113.00</td>\n",
       "      <td>0.05</td>\n",
       "      <td>...</td>\n",
       "      <td>20.811356</td>\n",
       "      <td>8.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.250000</td>\n",
       "      <td>32.194444</td>\n",
       "      <td>177335.833333</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3.600000</td>\n",
       "      <td>4.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS2016041403276</th>\n",
       "      <td>36.0</td>\n",
       "      <td>10.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>10.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.535714</td>\n",
       "      <td>11.006672</td>\n",
       "      <td>1112.55</td>\n",
       "      <td>113.00</td>\n",
       "      <td>0.05</td>\n",
       "      <td>...</td>\n",
       "      <td>20.811356</td>\n",
       "      <td>8.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.250000</td>\n",
       "      <td>32.194444</td>\n",
       "      <td>177335.833333</td>\n",
       "      <td>2.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3.600000</td>\n",
       "      <td>4.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS2016041102704</th>\n",
       "      <td>35.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.518519</td>\n",
       "      <td>11.215958</td>\n",
       "      <td>1084.30</td>\n",
       "      <td>113.00</td>\n",
       "      <td>0.05</td>\n",
       "      <td>...</td>\n",
       "      <td>18.129337</td>\n",
       "      <td>8.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.228571</td>\n",
       "      <td>32.687500</td>\n",
       "      <td>180186.875000</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>3.888889</td>\n",
       "      <td>4.375000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS2016040702548</th>\n",
       "      <td>34.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.518519</td>\n",
       "      <td>11.215958</td>\n",
       "      <td>1084.05</td>\n",
       "      <td>113.00</td>\n",
       "      <td>0.05</td>\n",
       "      <td>...</td>\n",
       "      <td>18.707499</td>\n",
       "      <td>8.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.205882</td>\n",
       "      <td>37.321429</td>\n",
       "      <td>205728.571429</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3.777778</td>\n",
       "      <td>4.250000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS2016040502427</th>\n",
       "      <td>34.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.518519</td>\n",
       "      <td>11.215958</td>\n",
       "      <td>1084.05</td>\n",
       "      <td>113.00</td>\n",
       "      <td>0.05</td>\n",
       "      <td>...</td>\n",
       "      <td>18.707499</td>\n",
       "      <td>8.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.205882</td>\n",
       "      <td>37.321429</td>\n",
       "      <td>205728.571429</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3.777778</td>\n",
       "      <td>4.250000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS2016040502426</th>\n",
       "      <td>34.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.518519</td>\n",
       "      <td>11.215958</td>\n",
       "      <td>1084.05</td>\n",
       "      <td>113.00</td>\n",
       "      <td>0.05</td>\n",
       "      <td>...</td>\n",
       "      <td>18.707499</td>\n",
       "      <td>8.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.205882</td>\n",
       "      <td>37.321429</td>\n",
       "      <td>205728.571429</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3.777778</td>\n",
       "      <td>4.250000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS2016040502418</th>\n",
       "      <td>34.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.518519</td>\n",
       "      <td>11.215958</td>\n",
       "      <td>1084.05</td>\n",
       "      <td>113.00</td>\n",
       "      <td>0.05</td>\n",
       "      <td>...</td>\n",
       "      <td>18.707499</td>\n",
       "      <td>8.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.205882</td>\n",
       "      <td>37.321429</td>\n",
       "      <td>205728.571429</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3.777778</td>\n",
       "      <td>4.250000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS2016032301514</th>\n",
       "      <td>31.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.666667</td>\n",
       "      <td>11.764599</td>\n",
       "      <td>938.05</td>\n",
       "      <td>80.00</td>\n",
       "      <td>0.05</td>\n",
       "      <td>...</td>\n",
       "      <td>20.529513</td>\n",
       "      <td>7.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.129032</td>\n",
       "      <td>28.812500</td>\n",
       "      <td>153977.500000</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3.444444</td>\n",
       "      <td>4.428571</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS2016032201382</th>\n",
       "      <td>31.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.666667</td>\n",
       "      <td>11.764599</td>\n",
       "      <td>938.05</td>\n",
       "      <td>80.00</td>\n",
       "      <td>0.05</td>\n",
       "      <td>...</td>\n",
       "      <td>20.529513</td>\n",
       "      <td>7.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.129032</td>\n",
       "      <td>28.812500</td>\n",
       "      <td>153977.500000</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3.444444</td>\n",
       "      <td>4.428571</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS2016031400348</th>\n",
       "      <td>30.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.666667</td>\n",
       "      <td>11.764599</td>\n",
       "      <td>910.05</td>\n",
       "      <td>80.00</td>\n",
       "      <td>0.05</td>\n",
       "      <td>...</td>\n",
       "      <td>21.237732</td>\n",
       "      <td>7.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.100000</td>\n",
       "      <td>29.083333</td>\n",
       "      <td>155836.666667</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3.333333</td>\n",
       "      <td>4.285714</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>YS2016030700026</th>\n",
       "      <td>28.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>10.043478</td>\n",
       "      <td>11.879999</td>\n",
       "      <td>850.80</td>\n",
       "      <td>80.00</td>\n",
       "      <td>0.05</td>\n",
       "      <td>...</td>\n",
       "      <td>22.810215</td>\n",
       "      <td>7.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.035714</td>\n",
       "      <td>28.000000</td>\n",
       "      <td>147560.000000</td>\n",
       "      <td>1.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3.111111</td>\n",
       "      <td>4.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1430 rows × 27 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                  订单总数  合作时间（月）  最近交易（X月之前）  最近连续交易月数  采购断档总月数  订单时间间隔均值（天）  \\\n",
       "YS20170228152309  18.0     12.0         1.0       2.0      1.0    18.588235   \n",
       "YS20170103150373  16.0      9.0         3.0       9.0      0.0    16.333333   \n",
       "YS20161117147341  15.0      9.0         1.0       9.0      0.0    16.642857   \n",
       "YS20161115147142  15.0      9.0         1.0       9.0      0.0    16.642857   \n",
       "YS20161025145675  14.0      9.0         0.0       9.0      0.0    17.769231   \n",
       "YS20161019110425  14.0      9.0         0.0       9.0      0.0    17.769231   \n",
       "YS20160926108844  12.0      7.0         1.0       7.0      0.0    16.090909   \n",
       "YS20160926108834  12.0      7.0         1.0       7.0      0.0    16.090909   \n",
       "YS20160824106578  11.0      7.0         0.0       7.0      0.0    16.700000   \n",
       "YS20160811171089  10.0      7.0         0.0       7.0      0.0    17.777778   \n",
       "YS2016080317738    9.0      6.0         1.0       6.0      0.0    18.250000   \n",
       "YS2016071915487    8.0      5.0         1.0       5.0      0.0    17.142857   \n",
       "YS2016070113517    7.0      5.0         1.0       5.0      0.0    18.500000   \n",
       "YS2016061410728    6.0      4.0         1.0       4.0      0.0    14.200000   \n",
       "YS2016050505611    5.0      3.0         1.0       3.0      0.0    12.250000   \n",
       "YS2016041503344    4.0      2.0         1.0       2.0      0.0    11.333333   \n",
       "YS2016033002161    3.0      2.0         0.0       2.0      0.0    14.500000   \n",
       "YS2016032801981    2.0      2.0         0.0       2.0      0.0    13.000000   \n",
       "YS2016031500502    1.0      1.0         NaN       1.0      0.0          NaN   \n",
       "YS2016031500501    1.0      1.0         NaN       1.0      0.0          NaN   \n",
       "YS20170313152947  13.0     12.0         4.0       3.0      2.0    26.833333   \n",
       "YS20170310152860  13.0     12.0         4.0       3.0      2.0    26.833333   \n",
       "YS20170306152576  13.0     12.0         4.0       3.0      2.0    26.833333   \n",
       "YS20161214149147  12.0     11.0         2.0       2.0      2.0    26.636364   \n",
       "YS20161201148307  12.0     11.0         2.0       2.0      2.0    26.636364   \n",
       "YS20161130148192  12.0     11.0         1.0       2.0      2.0    26.636364   \n",
       "YS20161019110385  11.0     10.0         1.0       1.0      2.0    26.000000   \n",
       "YS20160913107905  10.0      8.0         2.0       3.0      1.0    23.444444   \n",
       "YS20160911107730  10.0      8.0         2.0       3.0      1.0    23.444444   \n",
       "YS2016072516482    9.0      7.0         1.0       2.0      1.0    23.625000   \n",
       "...                ...      ...         ...       ...      ...          ...   \n",
       "YS20161008109412  51.0     15.0         1.0      15.0      0.0    10.309524   \n",
       "YS20160923108748  50.0     15.0         0.0      15.0      0.0    10.309524   \n",
       "YS20160905107298  47.0     13.0         2.0      13.0      0.0     9.717949   \n",
       "YS20160824106576  47.0     13.0         1.0      13.0      0.0     9.717949   \n",
       "YS20160812171110  47.0     13.0         1.0      13.0      0.0     9.717949   \n",
       "YS2016072917121   45.0     13.0         0.0      13.0      0.0     9.783784   \n",
       "YS2016071815393   45.0     13.0         0.0      13.0      0.0     9.783784   \n",
       "YS2016070814239   41.0     11.0         1.0      11.0      0.0     9.151515   \n",
       "YS2016070814238   40.0     11.0         1.0      11.0      0.0     9.343750   \n",
       "YS2016070413660   43.0     12.0         1.0      12.0      0.0     9.714286   \n",
       "YS2016062913095   42.0     12.0         0.0      12.0      0.0     9.794118   \n",
       "YS2016061410578   41.0     11.0         1.0      11.0      0.0     9.151515   \n",
       "YS2016060209464   40.0     11.0         0.0      11.0      0.0     9.343750   \n",
       "YS2016060109379   40.0     11.0         1.0      11.0      0.0     9.343750   \n",
       "YS2016051807334   40.0     11.0         0.0      11.0      0.0     9.343750   \n",
       "YS2016051606780   39.0     11.0         0.0      11.0      0.0     9.516129   \n",
       "YS2016051006122   38.0     10.0         1.0      10.0      0.0     9.333333   \n",
       "YS2016042905377   37.0     10.0         0.0      10.0      0.0     9.379310   \n",
       "YS2016042705087   37.0     10.0         0.0      10.0      0.0     9.379310   \n",
       "YS2016041803663   36.0     10.0         0.0      10.0      0.0     9.535714   \n",
       "YS2016041403276   36.0     10.0         0.0      10.0      0.0     9.535714   \n",
       "YS2016041102704   35.0      9.0         1.0       9.0      0.0     9.518519   \n",
       "YS2016040702548   34.0      9.0         0.0       9.0      0.0     9.518519   \n",
       "YS2016040502427   34.0      9.0         0.0       9.0      0.0     9.518519   \n",
       "YS2016040502426   34.0      9.0         0.0       9.0      0.0     9.518519   \n",
       "YS2016040502418   34.0      9.0         0.0       9.0      0.0     9.518519   \n",
       "YS2016032301514   31.0      9.0         0.0       9.0      0.0     9.666667   \n",
       "YS2016032201382   31.0      9.0         0.0       9.0      0.0     9.666667   \n",
       "YS2016031400348   30.0      9.0         0.0       9.0      0.0     9.666667   \n",
       "YS2016030700026   28.0      9.0         0.0       9.0      0.0    10.043478   \n",
       "\n",
       "                  订单时间间隔方差（天）     交易总量  交易量最大值  交易量最小值        ...          \\\n",
       "YS20170228152309    15.544528   556.75   54.00   20.00        ...           \n",
       "YS20170103150373    10.668155   502.75   54.00   20.00        ...           \n",
       "YS20161117147341    11.000749   448.75   50.00   20.00        ...           \n",
       "YS20161115147142    11.000749   448.75   50.00   20.00        ...           \n",
       "YS20161025145675    10.576340   422.75   50.00   20.00        ...           \n",
       "YS20161019110425    10.576340   422.75   50.00   20.00        ...           \n",
       "YS20160926108844    10.064338   346.75   50.00   20.00        ...           \n",
       "YS20160926108834    10.064338   346.75   50.00   20.00        ...           \n",
       "YS20160824106578    10.392839   315.75   50.00   20.00        ...           \n",
       "YS20160811171089    10.413666   284.75   50.00   20.00        ...           \n",
       "YS2016080317738     11.029182   264.75   50.00   20.00        ...           \n",
       "YS2016071915487     11.422617   244.75   50.00   20.00        ...           \n",
       "YS2016070113517     11.878552   216.50   50.00   20.00        ...           \n",
       "YS2016061410728      6.140033   188.25   50.00   20.00        ...           \n",
       "YS2016050505611      4.991660   160.00   50.00   20.00        ...           \n",
       "YS2016041503344      5.686241   130.00   50.00   20.00        ...           \n",
       "YS2016033002161      2.121320   110.00   50.00   20.00        ...           \n",
       "YS2016032801981      0.000000    90.00   50.00   40.00        ...           \n",
       "YS2016031500502           NaN    40.00   40.00   40.00        ...           \n",
       "YS2016031500501           NaN    40.00   40.00   40.00        ...           \n",
       "YS20170313152947    19.192012   624.00   78.75   26.00        ...           \n",
       "YS20170310152860    19.192012   624.00   78.75   26.00        ...           \n",
       "YS20170306152576    19.192012   624.00   78.75   26.00        ...           \n",
       "YS20161214149147    20.116027   545.25   60.00   26.00        ...           \n",
       "YS20161201148307    20.116027   545.25   60.00   26.00        ...           \n",
       "YS20161130148192    20.116027   545.25   60.00   26.00        ...           \n",
       "YS20161019110385    21.087121   519.25   60.00   28.00        ...           \n",
       "YS20160913107905    20.658601   459.25   60.00   28.00        ...           \n",
       "YS20160911107730    20.658601   459.25   60.00   28.00        ...           \n",
       "YS2016072516482     22.077380   402.75   60.00   28.00        ...           \n",
       "...                       ...      ...     ...     ...        ...           \n",
       "YS20161008109412    10.966664  1670.05  113.00    0.05        ...           \n",
       "YS20160923108748    10.966664  1644.05  113.00    0.05        ...           \n",
       "YS20160905107298    10.236541  1552.05  113.00    0.05        ...           \n",
       "YS20160824106576    10.236541  1552.05  113.00    0.05        ...           \n",
       "YS20160812171110    10.236541  1552.05  113.00    0.05        ...           \n",
       "YS2016072917121     10.363223  1459.05  113.00    0.05        ...           \n",
       "YS2016071815393     10.363223  1459.05  113.00    0.05        ...           \n",
       "YS2016070814239     10.295998  1341.05  113.00    0.05        ...           \n",
       "YS2016070814238     10.400401  1281.05  113.00    0.05        ...           \n",
       "YS2016070413660     10.659355  1397.05  113.00    0.05        ...           \n",
       "YS2016062913095     10.809029  1369.05  113.00    0.05        ...           \n",
       "YS2016061410578     10.295998  1341.05  113.00    0.05        ...           \n",
       "YS2016060209464     10.400401  1281.05  113.00    0.05        ...           \n",
       "YS2016060109379     10.400401  1281.05  113.00    0.05        ...           \n",
       "YS2016051807334     10.400401  1281.05  113.00    0.05        ...           \n",
       "YS2016051606780     10.525749  1225.05  113.00    0.05        ...           \n",
       "YS2016051006122     10.655526  1197.05  113.00    0.05        ...           \n",
       "YS2016042905377     10.841105  1140.55  113.00    0.05        ...           \n",
       "YS2016042705087     10.841105  1140.55  113.00    0.05        ...           \n",
       "YS2016041803663     11.006672  1112.55  113.00    0.05        ...           \n",
       "YS2016041403276     11.006672  1112.55  113.00    0.05        ...           \n",
       "YS2016041102704     11.215958  1084.30  113.00    0.05        ...           \n",
       "YS2016040702548     11.215958  1084.05  113.00    0.05        ...           \n",
       "YS2016040502427     11.215958  1084.05  113.00    0.05        ...           \n",
       "YS2016040502426     11.215958  1084.05  113.00    0.05        ...           \n",
       "YS2016040502418     11.215958  1084.05  113.00    0.05        ...           \n",
       "YS2016032301514     11.764599   938.05   80.00    0.05        ...           \n",
       "YS2016032201382     11.764599   938.05   80.00    0.05        ...           \n",
       "YS2016031400348     11.764599   910.05   80.00    0.05        ...           \n",
       "YS2016030700026     11.879999   850.80   80.00    0.05        ...           \n",
       "\n",
       "                      交易稳定性  供应商数量  采购产品种类数量    账期订单占比  账期订单交易量均值  \\\n",
       "YS20170228152309   0.062321    5.0       1.0  0.888889  30.609375   \n",
       "YS20170103150373   0.103964    5.0       1.0  0.937500  30.850000   \n",
       "YS20161117147341   0.034467    5.0       1.0  0.933333  29.196429   \n",
       "YS20161115147142   0.034467    5.0       1.0  0.933333  29.196429   \n",
       "YS20161025145675   0.037118    5.0       1.0  0.928571  29.442308   \n",
       "YS20161019110425   0.037118    5.0       1.0  0.928571  29.442308   \n",
       "YS20160926108844   0.031785    5.0       1.0  0.916667  27.886364   \n",
       "YS20160926108834   0.031785    5.0       1.0  0.916667  27.886364   \n",
       "YS20160824106578   0.034963    5.0       1.0  0.909091  27.575000   \n",
       "YS20160811171089  -0.022263    4.0       1.0  0.900000  27.194444   \n",
       "YS2016080317738   -0.025046    4.0       1.0  0.888889  28.093750   \n",
       "YS2016071915487    0.013095    3.0       1.0  0.875000  29.250000   \n",
       "YS2016070113517    0.015278    3.0       1.0  0.857143  29.416667   \n",
       "YS2016061410728    0.018333    3.0       1.0  0.833333  29.650000   \n",
       "YS2016050505611    0.037500    2.0       1.0  0.800000  30.000000   \n",
       "YS2016041503344   -0.116667    1.0       1.0  0.750000  30.000000   \n",
       "YS2016033002161   -0.175000    1.0       1.0  0.666667  35.000000   \n",
       "YS2016032801981    0.250000    1.0       1.0  0.500000  50.000000   \n",
       "YS2016031500502    0.000000    1.0       1.0  0.000000   0.000000   \n",
       "YS2016031500501    0.000000    1.0       1.0  0.000000   0.000000   \n",
       "YS20170313152947   0.250159    4.0       1.0  0.769231  47.750000   \n",
       "YS20170310152860   0.250159    4.0       1.0  0.769231  47.750000   \n",
       "YS20170306152576   0.250159    4.0       1.0  0.769231  47.750000   \n",
       "YS20161214149147   0.088460    4.0       1.0  0.750000  44.305556   \n",
       "YS20161201148307   0.088460    4.0       1.0  0.750000  44.305556   \n",
       "YS20161130148192   0.088460    4.0       1.0  0.750000  44.305556   \n",
       "YS20161019110385   0.153973    3.0       1.0  0.727273  46.593750   \n",
       "YS20160913107905   0.164198    3.0       1.0  0.700000  44.678571   \n",
       "YS20160911107730   0.164198    3.0       1.0  0.700000  44.678571   \n",
       "YS2016072516482    0.057490    3.0       1.0  0.666667  42.708333   \n",
       "...                     ...    ...       ...       ...        ...   \n",
       "YS20161008109412  14.597634   12.0       1.0  0.470588  35.302083   \n",
       "YS20160923108748  14.898266   12.0       1.0  0.460000  35.706522   \n",
       "YS20160905107298  15.881463   12.0       1.0  0.425532  36.462500   \n",
       "YS20160824106576  15.881463   12.0       1.0  0.425532  36.462500   \n",
       "YS20160812171110  15.881463   12.0       1.0  0.425532  36.462500   \n",
       "YS2016072917121   16.580620   12.0       1.0  0.400000  35.347222   \n",
       "YS2016071815393   16.580620   12.0       1.0  0.400000  35.347222   \n",
       "YS2016070814239   18.249337   10.0       1.0  0.341463  37.017857   \n",
       "YS2016070814238   18.715437    9.0       1.0  0.325000  35.250000   \n",
       "YS2016070413660   17.367622   11.0       1.0  0.372093  35.890625   \n",
       "YS2016062913095   17.791223   11.0       1.0  0.357143  36.416667   \n",
       "YS2016061410578   18.249337   10.0       1.0  0.341463  37.017857   \n",
       "YS2016060209464   18.715437    9.0       1.0  0.325000  35.250000   \n",
       "YS2016060109379   18.715437    9.0       1.0  0.325000  35.250000   \n",
       "YS2016051807334   18.715437    9.0       1.0  0.325000  35.250000   \n",
       "YS2016051606780   19.181633    9.0       1.0  0.307692  33.520833   \n",
       "YS2016051006122   19.713688    8.0       1.0  0.289474  34.022727   \n",
       "YS2016042905377   20.233017    8.0       1.0  0.270270  31.775000   \n",
       "YS2016042705087   20.233017    8.0       1.0  0.270270  31.775000   \n",
       "YS2016041803663   20.811356    8.0       1.0  0.250000  32.194444   \n",
       "YS2016041403276   20.811356    8.0       1.0  0.250000  32.194444   \n",
       "YS2016041102704   18.129337    8.0       1.0  0.228571  32.687500   \n",
       "YS2016040702548   18.707499    8.0       1.0  0.205882  37.321429   \n",
       "YS2016040502427   18.707499    8.0       1.0  0.205882  37.321429   \n",
       "YS2016040502426   18.707499    8.0       1.0  0.205882  37.321429   \n",
       "YS2016040502418   18.707499    8.0       1.0  0.205882  37.321429   \n",
       "YS2016032301514   20.529513    7.0       1.0  0.129032  28.812500   \n",
       "YS2016032201382   20.529513    7.0       1.0  0.129032  28.812500   \n",
       "YS2016031400348   21.237732    7.0       1.0  0.100000  29.083333   \n",
       "YS2016030700026   22.810215    7.0       1.0  0.035714  28.000000   \n",
       "\n",
       "                      账期订单交易额均值  账期合作时间（月）  最近一笔账期订单（X月之前）  采购频率（订单总数/合作月数）  \\\n",
       "YS20170228152309  188399.218750       10.0             2.0         1.500000   \n",
       "YS20170103150373  189493.166667        8.0             3.0         1.777778   \n",
       "YS20161117147341  174678.392857        8.0             1.0         1.666667   \n",
       "YS20161115147142  174678.392857        8.0             1.0         1.666667   \n",
       "YS20161025145675  173615.192308        8.0             0.0         1.555556   \n",
       "YS20161019110425  173615.192308        8.0             0.0         1.555556   \n",
       "YS20160926108844  156459.772727        6.0             1.0         1.714286   \n",
       "YS20160926108834  156459.772727        6.0             1.0         1.714286   \n",
       "YS20160824106578  153226.750000        6.0             0.0         1.571429   \n",
       "YS20160811171089  150101.944444        6.0             0.0         1.428571   \n",
       "YS2016080317738   154389.687500        5.0             1.0         1.500000   \n",
       "YS2016071915487   159931.071429        4.0             1.0         1.600000   \n",
       "YS2016070113517   161490.833333        4.0             1.0         1.400000   \n",
       "YS2016061410728   163731.000000        3.0             1.0         1.500000   \n",
       "YS2016050505611   166950.000000        2.0             1.0         1.666667   \n",
       "YS2016041503344   166900.000000        1.0             1.0         2.000000   \n",
       "YS2016033002161   193550.000000        1.0             0.0         1.500000   \n",
       "YS2016032801981   273500.000000        1.0             NaN         1.000000   \n",
       "YS2016031500502        0.000000        0.0             NaN         1.000000   \n",
       "YS2016031500501        0.000000        0.0             NaN         1.000000   \n",
       "YS20170313152947  291668.250000        9.0             4.0         1.083333   \n",
       "YS20170310152860  291668.250000        9.0             4.0         1.083333   \n",
       "YS20170306152576  291668.250000        9.0             4.0         1.083333   \n",
       "YS20161214149147  252063.333333        8.0             2.0         1.090909   \n",
       "YS20161201148307  252063.333333        8.0             2.0         1.090909   \n",
       "YS20161130148192  252063.333333        8.0             1.0         1.090909   \n",
       "YS20161019110385  259911.250000        7.0             1.0         1.100000   \n",
       "YS20160913107905  243555.714286        5.0             2.0         1.250000   \n",
       "YS20160911107730  243555.714286        5.0             2.0         1.250000   \n",
       "YS2016072516482   230567.500000        4.0             1.0         1.285714   \n",
       "...                         ...        ...             ...              ...   \n",
       "YS20161008109412  199068.437500        7.0             1.0         3.400000   \n",
       "YS20160923108748  199980.108696        7.0             0.0         3.333333   \n",
       "YS20160905107298  200576.625000        5.0             2.0         3.615385   \n",
       "YS20160824106576  200576.625000        5.0             1.0         3.615385   \n",
       "YS20160812171110  200576.625000        5.0             1.0         3.615385   \n",
       "YS2016072917121   193602.361111        5.0             0.0         3.461538   \n",
       "YS2016071815393   193602.361111        5.0             0.0         3.461538   \n",
       "YS2016070814239   202824.464286        3.0             1.0         3.727273   \n",
       "YS2016070814238   193180.192308        3.0             1.0         3.636364   \n",
       "YS2016070413660   196528.906250        4.0             1.0         3.583333   \n",
       "YS2016062913095   199214.833333        4.0             0.0         3.500000   \n",
       "YS2016061410578   202824.464286        3.0             1.0         3.727273   \n",
       "YS2016060209464   193180.192308        3.0             0.0         3.636364   \n",
       "YS2016060109379   193180.192308        3.0             1.0         3.636364   \n",
       "YS2016051807334   193180.192308        3.0             0.0         3.636364   \n",
       "YS2016051606780   184498.541667        3.0             0.0         3.545455   \n",
       "YS2016051006122   187754.772727        2.0             1.0         3.800000   \n",
       "YS2016042905377   174890.250000        2.0             0.0         3.700000   \n",
       "YS2016042705087   174890.250000        2.0             0.0         3.700000   \n",
       "YS2016041803663   177335.833333        2.0             0.0         3.600000   \n",
       "YS2016041403276   177335.833333        2.0             0.0         3.600000   \n",
       "YS2016041102704   180186.875000        1.0             1.0         3.888889   \n",
       "YS2016040702548   205728.571429        1.0             0.0         3.777778   \n",
       "YS2016040502427   205728.571429        1.0             0.0         3.777778   \n",
       "YS2016040502426   205728.571429        1.0             0.0         3.777778   \n",
       "YS2016040502418   205728.571429        1.0             0.0         3.777778   \n",
       "YS2016032301514   153977.500000        1.0             0.0         3.444444   \n",
       "YS2016032201382   153977.500000        1.0             0.0         3.444444   \n",
       "YS2016031400348   155836.666667        1.0             0.0         3.333333   \n",
       "YS2016030700026   147560.000000        1.0             NaN         3.111111   \n",
       "\n",
       "                  采购聚集程度（订单总数/供应商数）  \n",
       "YS20170228152309           3.600000  \n",
       "YS20170103150373           3.200000  \n",
       "YS20161117147341           3.000000  \n",
       "YS20161115147142           3.000000  \n",
       "YS20161025145675           2.800000  \n",
       "YS20161019110425           2.800000  \n",
       "YS20160926108844           2.400000  \n",
       "YS20160926108834           2.400000  \n",
       "YS20160824106578           2.200000  \n",
       "YS20160811171089           2.500000  \n",
       "YS2016080317738            2.250000  \n",
       "YS2016071915487            2.666667  \n",
       "YS2016070113517            2.333333  \n",
       "YS2016061410728            2.000000  \n",
       "YS2016050505611            2.500000  \n",
       "YS2016041503344            4.000000  \n",
       "YS2016033002161            3.000000  \n",
       "YS2016032801981            2.000000  \n",
       "YS2016031500502            1.000000  \n",
       "YS2016031500501            1.000000  \n",
       "YS20170313152947           3.250000  \n",
       "YS20170310152860           3.250000  \n",
       "YS20170306152576           3.250000  \n",
       "YS20161214149147           3.000000  \n",
       "YS20161201148307           3.000000  \n",
       "YS20161130148192           3.000000  \n",
       "YS20161019110385           3.666667  \n",
       "YS20160913107905           3.333333  \n",
       "YS20160911107730           3.333333  \n",
       "YS2016072516482            3.000000  \n",
       "...                             ...  \n",
       "YS20161008109412           4.250000  \n",
       "YS20160923108748           4.166667  \n",
       "YS20160905107298           3.916667  \n",
       "YS20160824106576           3.916667  \n",
       "YS20160812171110           3.916667  \n",
       "YS2016072917121            3.750000  \n",
       "YS2016071815393            3.750000  \n",
       "YS2016070814239            4.100000  \n",
       "YS2016070814238            4.444444  \n",
       "YS2016070413660            3.909091  \n",
       "YS2016062913095            3.818182  \n",
       "YS2016061410578            4.100000  \n",
       "YS2016060209464            4.444444  \n",
       "YS2016060109379            4.444444  \n",
       "YS2016051807334            4.444444  \n",
       "YS2016051606780            4.333333  \n",
       "YS2016051006122            4.750000  \n",
       "YS2016042905377            4.625000  \n",
       "YS2016042705087            4.625000  \n",
       "YS2016041803663            4.500000  \n",
       "YS2016041403276            4.500000  \n",
       "YS2016041102704            4.375000  \n",
       "YS2016040702548            4.250000  \n",
       "YS2016040502427            4.250000  \n",
       "YS2016040502426            4.250000  \n",
       "YS2016040502418            4.250000  \n",
       "YS2016032301514            4.428571  \n",
       "YS2016032201382            4.428571  \n",
       "YS2016031400348            4.285714  \n",
       "YS2016030700026            4.000000  \n",
       "\n",
       "[1430 rows x 27 columns]"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "samples['采购频率（订单总数/合作月数）'] =samples['订单总数']*1.0/samples['合作时间（月）']\n",
    "samples['采购聚集程度（订单总数/供应商数）'] =samples['订单总数']*1.0/samples['供应商数量']\n",
    "samples.to_csv('./data/zq_feature_trade.csv')\n",
    "samples"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 逾期样本订单"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(1430, 15)"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#所有逾期记录\n",
    "files = os.listdir('./data/loan_list/')\n",
    "loan_all = pd.DataFrame()\n",
    "for f in files:\n",
    "    record = pd.read_excel(os.path.join('./data/loan_list/',f))\n",
    "    loan_all = loan_all.append(record.iloc[1:,:],ignore_index=True)\n",
    "loan_all['zq_day'] = loan_all[u'账期'].apply(lambda x:re.findall('\\d+',x)[0])\n",
    "loan_all['yq_day'] = loan_all[u'逾期'].apply(lambda x:re.findall('^(-\\d+|\\d+)',x)[0])\n",
    "loan_all['zq_day'] = loan_all['zq_day'].astype(int)\n",
    "loan_all['yq_day'] = loan_all['yq_day'].apply(lambda x:int(x))\n",
    "loan_all.to_csv('./data/loan_all.csv',index=None)\n",
    "loan_all=loan_all.drop_duplicates()\n",
    "loan_all.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(1430, 20)"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "loan_all['4天以内占比']=0\n",
    "loan_all['5-10天占比']=0\n",
    "loan_all['11天以上占比']=0\n",
    "loan_all[u'逾期占比']=0\n",
    "loan_all[u'提前还款占比']=0\n",
    "loan_all.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def yq_sts(list):\n",
    "    yq_4=0\n",
    "    yq_10=0\n",
    "    yq_11=0\n",
    "    zq_num = len(list)\n",
    "    for i in list:\n",
    "        if i>0 and i<=4:\n",
    "            yq_4+=1\n",
    "        elif i>4 and i<=10:\n",
    "            yq_10+=1\n",
    "        elif i>10:\n",
    "            yq_11+=1\n",
    "            \n",
    "    return yq_4*1.0/zq_num,yq_10*1.0/zq_num,yq_11*1.0/zq_num"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>业务类型</th>\n",
       "      <th>客户</th>\n",
       "      <th>已收金额</th>\n",
       "      <th>应收</th>\n",
       "      <th>应收余额</th>\n",
       "      <th>应收单号</th>\n",
       "      <th>应收总额</th>\n",
       "      <th>应收日期</th>\n",
       "      <th>收款状态</th>\n",
       "      <th>账期</th>\n",
       "      <th>...</th>\n",
       "      <th>逾期</th>\n",
       "      <th>销售合同号</th>\n",
       "      <th>zq_day</th>\n",
       "      <th>yq_day</th>\n",
       "      <th>4天以内占比</th>\n",
       "      <th>5-10天占比</th>\n",
       "      <th>11天以上占比</th>\n",
       "      <th>逾期占比</th>\n",
       "      <th>提前还款占比</th>\n",
       "      <th>平均逾期天数</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>账期业务</td>\n",
       "      <td>佛山市南海区松岗明珠塑料有限公司</td>\n",
       "      <td>184520.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>YS20170228152309</td>\n",
       "      <td>184520.0</td>\n",
       "      <td>2017-03-30</td>\n",
       "      <td>已收款</td>\n",
       "      <td>30天</td>\n",
       "      <td>...</td>\n",
       "      <td>11天</td>\n",
       "      <td>ZSL20170227LL-C003WJ</td>\n",
       "      <td>30</td>\n",
       "      <td>11</td>\n",
       "      <td>0.157895</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.157895</td>\n",
       "      <td>0.263158</td>\n",
       "      <td>1.333333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>账期业务</td>\n",
       "      <td>佛山市南海区松岗明珠塑料有限公司</td>\n",
       "      <td>171990.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>YS20170103150373</td>\n",
       "      <td>171990.0</td>\n",
       "      <td>2017-01-13</td>\n",
       "      <td>已收款</td>\n",
       "      <td>10天</td>\n",
       "      <td>...</td>\n",
       "      <td>0天</td>\n",
       "      <td>ZSL20161228LL-C041WJ</td>\n",
       "      <td>10</td>\n",
       "      <td>0</td>\n",
       "      <td>0.166667</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.166667</td>\n",
       "      <td>0.277778</td>\n",
       "      <td>1.333333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>账期业务</td>\n",
       "      <td>佛山市南海区松岗明珠塑料有限公司</td>\n",
       "      <td>198450.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>YS20161117147341</td>\n",
       "      <td>198450.0</td>\n",
       "      <td>2016-12-02</td>\n",
       "      <td>已收款</td>\n",
       "      <td>15天</td>\n",
       "      <td>...</td>\n",
       "      <td>-2天</td>\n",
       "      <td>ZSL20161025LL-C009WJ</td>\n",
       "      <td>15</td>\n",
       "      <td>-2</td>\n",
       "      <td>0.176471</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.176471</td>\n",
       "      <td>0.235294</td>\n",
       "      <td>1.333333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>账期业务</td>\n",
       "      <td>佛山市南海区松岗明珠塑料有限公司</td>\n",
       "      <td>198450.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>YS20161115147142</td>\n",
       "      <td>198450.0</td>\n",
       "      <td>2016-11-29</td>\n",
       "      <td>已收款</td>\n",
       "      <td>15天</td>\n",
       "      <td>...</td>\n",
       "      <td>0天</td>\n",
       "      <td>ZSL20161025LL-C009WJ</td>\n",
       "      <td>15</td>\n",
       "      <td>0</td>\n",
       "      <td>0.187500</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.187500</td>\n",
       "      <td>0.250000</td>\n",
       "      <td>1.333333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>账期业务</td>\n",
       "      <td>佛山市南海区松岗明珠塑料有限公司</td>\n",
       "      <td>186940.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.0</td>\n",
       "      <td>YS20161025145675</td>\n",
       "      <td>186940.0</td>\n",
       "      <td>2016-11-09</td>\n",
       "      <td>已收款</td>\n",
       "      <td>15天</td>\n",
       "      <td>...</td>\n",
       "      <td>0天</td>\n",
       "      <td>ZSL20161011LL-C038WJ</td>\n",
       "      <td>15</td>\n",
       "      <td>0</td>\n",
       "      <td>0.200000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.200000</td>\n",
       "      <td>0.266667</td>\n",
       "      <td>1.333333</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 21 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   业务类型                客户      已收金额   应收  应收余额              应收单号      应收总额  \\\n",
       "0  账期业务  佛山市南海区松岗明珠塑料有限公司  184520.0  NaN   0.0  YS20170228152309  184520.0   \n",
       "1  账期业务  佛山市南海区松岗明珠塑料有限公司  171990.0  NaN   0.0  YS20170103150373  171990.0   \n",
       "2  账期业务  佛山市南海区松岗明珠塑料有限公司  198450.0  NaN   0.0  YS20161117147341  198450.0   \n",
       "3  账期业务  佛山市南海区松岗明珠塑料有限公司  198450.0  NaN   0.0  YS20161115147142  198450.0   \n",
       "4  账期业务  佛山市南海区松岗明珠塑料有限公司  186940.0  NaN   0.0  YS20161025145675  186940.0   \n",
       "\n",
       "        应收日期 收款状态   账期    ...      逾期                 销售合同号 zq_day  yq_day  \\\n",
       "0 2017-03-30  已收款  30天    ...     11天  ZSL20170227LL-C003WJ     30      11   \n",
       "1 2017-01-13  已收款  10天    ...      0天  ZSL20161228LL-C041WJ     10       0   \n",
       "2 2016-12-02  已收款  15天    ...     -2天  ZSL20161025LL-C009WJ     15      -2   \n",
       "3 2016-11-29  已收款  15天    ...      0天  ZSL20161025LL-C009WJ     15       0   \n",
       "4 2016-11-09  已收款  15天    ...      0天  ZSL20161011LL-C038WJ     15       0   \n",
       "\n",
       "     4天以内占比  5-10天占比  11天以上占比      逾期占比    提前还款占比    平均逾期天数  \n",
       "0  0.157895      0.0      0.0  0.157895  0.263158  1.333333  \n",
       "1  0.166667      0.0      0.0  0.166667  0.277778  1.333333  \n",
       "2  0.176471      0.0      0.0  0.176471  0.235294  1.333333  \n",
       "3  0.187500      0.0      0.0  0.187500  0.250000  1.333333  \n",
       "4  0.200000      0.0      0.0  0.200000  0.266667  1.333333  \n",
       "\n",
       "[5 rows x 21 columns]"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#统计\n",
    "yq_ratio =[]\n",
    "tq_ratio =[]\n",
    "yq_day_ratio =[]\n",
    "yq_avg =[]\n",
    "loan_all[u'起算日期'] =pd.to_datetime(loan_all[u'起算日期'])\n",
    "for i in xrange(loan_all.shape[0]):\n",
    "    name = loan_all.iat[i,1]\n",
    "    time = loan_all.iat[i,10]\n",
    "    loan_sub = loan_all[(loan_all[u'客户'] == name) & (loan_all[u'起算日期']<time)]\n",
    "    if loan_sub.shape[0]>0:\n",
    "        tmps = yq_sts(loan_sub['yq_day'])\n",
    "        yq_day_ratio.append(tmps)\n",
    "        yq_ratio.append(loan_sub[loan_sub['yq_day']>0].shape[0]*1.0 / loan_sub.shape[0])\n",
    "        tq_ratio.append( loan_sub[loan_sub['yq_day']<0].shape[0]*1.0 / loan_sub.shape[0])\n",
    "        if loan_sub[loan_sub['yq_day']>0].shape[0]>0:\n",
    "            yq_avg.append( loan_sub[loan_sub['yq_day']>0]['yq_day'].mean())\n",
    "        else:\n",
    "            yq_avg.append(0)\n",
    "    else:\n",
    "        yq_day_ratio.append((np.nan,np.nan,np.nan))\n",
    "        yq_ratio.append(np.nan)\n",
    "        tq_ratio.append(np.nan)\n",
    "        yq_avg.append(np.nan)\n",
    "\n",
    "loan_all['4天以内占比']=[x[0] for x in yq_day_ratio]\n",
    "loan_all['5-10天占比']=[x[1] for x in yq_day_ratio]\n",
    "loan_all['11天以上占比']=[x[2] for x in yq_day_ratio]\n",
    "loan_all[u'逾期占比']=yq_ratio\n",
    "loan_all[u'提前还款占比']=tq_ratio\n",
    "loan_all[u'平均逾期天数']=yq_avg\n",
    "loan_all.to_csv('./data/loan_all.csv',index=None)\n",
    "loan_all.head()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
